package com.lagou.task05;

import java.security.Policy;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

public class Player {

    //玩家类

    //姓名
    private String name;
    //所持有的牌
    private List<Poker> handPoker;

    //起牌动作
    public void getPoker(Poker p){
        handPoker.add(p);
        System.out.println(getName() + "摸牌成功：" + p);
    }

    //给手牌排序
    public void sortMyPoker(){
        //Collections.sort(handPoker,this::compare);

        Collections.sort(handPoker, new Comparator<Poker>() {
            @Override
            public int compare(Poker o1, Poker o2) {
                int c1 = o1.getSortFlag();
                int c2 = o2.getSortFlag();
                return c2-c1;
            }
        });
    }



    //亮牌
    public void show(){
        //先排序 后打印
        sortMyPoker();
        System.out.println(getName() + "手中的牌：");
        for (Poker p : handPoker) {
            System.out.print(p.getPoint() + ":" + p.getColorType() + " ");
        }
        System.out.println();
    }

    public Player(String name, List<Poker> handPoker) {
        this.name = name;
        this.handPoker = handPoker;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Poker> getHandPoker() {
        return handPoker;
    }

    public void setHandPoker(List<Poker> handPoker) {
        this.handPoker = handPoker;
    }

    public Player() {
    }
}
